package com.speedchina.permission.base.config;

import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.lang.reflect.Field;
import java.util.List;

/**
 * @author hank
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Profile({"dev", "test"})
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();

    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("速度脚手架-接口文档")
                .description("包含当前版本最基础的接口信息, POST/PUT 接口 parameters 表示必传字段，其余为选填")
                .contact(new Contact("速度应用开发团队", "http://www.speedchina.cn/", "office@speedchina.cn"))
                .version("1.0")
                .license("署名-非商用-相同方式共享 4.0转载请保留原文链接及作者")
                .licenseUrl("https://creativecommons.org/licenses/by-nc-sa/4.0/")
                .build();
    }

}